package com.example.itcompanyinterview;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.Window;

public class MainActivity extends Activity {

	private Handler handler;
	private static final int startCompanyAction = 0x1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main);
		this.initStartHandler();
		this.waitForOneSecond();
	}
	
	private void initStartHandler() {
		this.handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				if(msg.what == startCompanyAction ) {
					startCompanyListActivity();
				}
			}
		};
	}
	
	private void waitForOneSecond() {
		new Thread(new Runnable(){
			@Override
			public void run() {
				handler.sendEmptyMessageDelayed(startCompanyAction, 3000);
			}
		}).start();
	}
	
	private void startCompanyListActivity() {
		Intent intent = new Intent(MainActivity.this, GridScreenActivity.class);
		startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
